package com.finance.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.finance.entity.ApiLog;
import com.finance.mapper.ApiLogMapper;
import com.finance.service.ApiLogService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> implements ApiLogService {
    
    @Override
    public void logApiCall(String apiName, String dataType, Integer status, Integer dataCount,
                          String errorMessage, String requestParams, String responseData,String traceId,int retryCount) {
        ApiLog apiLog = new ApiLog();
        apiLog.setApiName(apiName);
        apiLog.setDataType(dataType);
        apiLog.setCallTime(LocalDateTime.now());
        apiLog.setStatus(status);
        apiLog.setDataCount(dataCount);
        apiLog.setErrorMessage(errorMessage);
        apiLog.setRequestParams(requestParams);
        apiLog.setTraceId(traceId);
        apiLog.setResponseData(responseData);
        apiLog.setRetryCount(retryCount);
        save(apiLog);
    }
} 